using System;
using System.ComponentModel;
using System.Collections.Generic;

using Castle.ActiveRecord;

/// <summary>
/// Business entity class generated from Product
/// </summary>
/// <remarks>
/// Created by: huanhvhd
/// Created date: [2011-04-23]
/// </remarks>
namespace TVN.ShopMan.ActiveModels
{
	[ActiveRecord("Product")]
	public partial class Product : ActiveRecordBase<Product>
	{
		#region Properties
		
        /// <summary>
        /// All properties
        /// </summary>
		public class Properties
		{
			public const string Id = "Id";
			public const string Name = "Name";
			public const string Description = "Description";
			public const string Cost = "Cost";
			public const string Price = "Price";
			public const string Quantity = "Quantity";
			public const string CreatedDate = "CreatedDate";
			public const string LastModifiedDate = "LastModifiedDate";
			public const string Creator = "Creator";
			public const string LastModifier = "LastModifier";
			public const string Supplier = "Supplier";
			public const string Unit = "Unit";
		}

		#endregion

		#region Private fields

		private int _id;
		private string _name;
		private string _description;
		private System.Decimal _cost;
		private System.Decimal _price;
		private System.Decimal _quantity;
		private DateTime _createdDate;
		private DateTime? _lastModifiedDate;
		private Account _creatorId;
		private Account _lastModifierId;
		private Supplier _supplierId;
		private Unit _unitId;

		private IList<ImportDetail> _importDetailsProductId = new List<ImportDetail>();
		private IList<ProductRepository> _productRepositoriesProductId = new List<ProductRepository>();
		private IList<SellDetail> _sellDetailsProductId = new List<SellDetail>();

		#endregion

		#region Constructors

		public Product()
		{
		}

		#endregion

		#region Properties

		[PrimaryKey("Id", Access = PropertyAccess.NosetterLowercaseUnderscore)]
		public int Id
		{
			get { return _id; }
		}

		[Property("Name", NotNull = true, Length = 256)]
		public string Name
		{
			get { return _name; }
			set { _name = value; }
		}

		[Property("Description", ColumnType = "StringClob")]
		public string Description
		{
			get { return _description; }
			set { _description = value; }
		}

		[Property("Cost", NotNull = true)]
		public System.Decimal Cost
		{
			get { return _cost; }
			set { _cost = value; }
		}

		[Property("Price", NotNull = true)]
		public System.Decimal Price
		{
			get { return _price; }
			set { _price = value; }
		}

		[Property("Quantity", NotNull = true)]
		public System.Decimal Quantity
		{
			get { return _quantity; }
			set { _quantity = value; }
		}

		[Property("CreatedDate", NotNull = true)]
		public DateTime CreatedDate
		{
			get { return _createdDate; }
			set { _createdDate = value; }
		}

		[Property("LastModifiedDate")]
		public DateTime? LastModifiedDate
		{
			get { return _lastModifiedDate; }
			set { _lastModifiedDate = value; }
		}

		[BelongsTo("CreatorId", Type = typeof(Account))]
		public Account Creator
		{
			get { return _creatorId; }
			set { _creatorId = value; }
		}

		[BelongsTo("LastModifierId", Type = typeof(Account))]
		public Account LastModifier
		{
			get { return _lastModifierId; }
			set { _lastModifierId = value; }
		}

		[BelongsTo("SupplierId", Type = typeof(Supplier))]
		public Supplier Supplier
		{
			get { return _supplierId; }
			set { _supplierId = value; }
		}

		[BelongsTo("UnitId", Type = typeof(Unit))]
		public Unit Unit
		{
			get { return _unitId; }
			set { _unitId = value; }
		}

		[HasMany(typeof(ImportDetail), Table="ImportDetail", ColumnKey="ProductId")]
		public IList<ImportDetail> ImportDetailsProductId
		{
			get { return _importDetailsProductId; }
			set { _importDetailsProductId = value; }
		}
		[HasMany(typeof(ProductRepository), Table="ProductRepository", ColumnKey="ProductId")]
		public IList<ProductRepository> ProductRepositoriesProductId
		{
			get { return _productRepositoriesProductId; }
			set { _productRepositoriesProductId = value; }
		}
		[HasMany(typeof(SellDetail), Table="SellDetail", ColumnKey="ProductId")]
		public IList<SellDetail> SellDetailsProductId
		{
			get { return _sellDetailsProductId; }
			set { _sellDetailsProductId = value; }
		}
		#endregion

	} }
